package com.thinktank.controller;

import static com.thinktank.util.DbUtil.*;

import java.io.*;
import java.sql.*;

import javax.servlet.ServletException;
import javax.servlet.http.*;

import com.thinktank.vo.Board;
import com.thinktank.dao.BoardDao;

public class BoardEditProcessController implements Controller  {
	public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String bNo = request.getParameter("bNo");
		String bSubject = request.getParameter("bSubject");
		String bContent = request.getParameter("bContent");
		String bCategory = request.getParameter("category");
		
		
		Board board = new Board();
		board.setbNo(bNo);
		board.setbSubject(bSubject);
		board.setbContent(bContent);
		board.setbCategory(bCategory);
		
		Connection con = getConnection();
		BoardDao dao = new BoardDao(con);
		int result = dao.update(board);
		close(con);
		if(result == 0) {
			return "error.jsp";
		}
		
		return "redirect:boardDetail.do?bNo=" +bNo;
		}
}
